var CalUtil = function() {
	
}

CalUtil.prototype = {
	constructor: CalUtil,
	add: function(...vars) {
		return this.cal("add", vars);
	},
	sub: function(...vars) {
		return this.cal("sub", vars);
	},
	mul: function(...vars) {
		return this.cal("mul", vars);
	},
	div: function(...vars) {
		return this.cal("div", vars);
	},
	cal: function(type, vars) {
		var calvars = vars;
		var first = this.checkType(vars[0]);
		for (var ind = 1; ind < calvars.length; ind++) {
			if (type == "add") {
				first=new Big(this.checkType(calvars[ind])).plus(first);
			}
			if (type == "sub") {
				first= new Big(-this.checkType(calvars[ind])).plus(first);
			}
			if (type == "mul") {
				first=new Big(this.checkType(calvars[ind])).times(first);
			}
			if (type == "div") {
				first=new Big(first).div(this.checkType(calvars[ind]));
			}
		}
		return Number(first.toString());
	},
	checkType: function(var2) {
		//可以有个空格  验证是否为数字
		var reg =/^(\s|\-|\+)?\d+(\.\d+)?$/;
		if (!reg.test(var2)) {
			throw Error("参数应为数字");
		}
		return Number(var2);
	},
}
